package com.senlingspace.web.controller.headquarters;

import java.util.Objects;

import com.alibaba.fastjson2.JSON;
import com.senlingspace.system.domain.dto.ProjectTicketFareManagementDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.senlingspace.common.annotation.Log;
import com.senlingspace.common.core.controller.BaseController;
import com.senlingspace.common.core.domain.AjaxResult;
import com.senlingspace.common.enums.BusinessType;
import com.senlingspace.system.service.ISlkjProjectTicketFareService;

/**
 * 项目_票价 管理 Controller
 *
 * @author SenlingSpace
 * @date 2024-07-03
 */
@Deprecated
@Slf4j
@RestController
@RequestMapping("/system/fare")
public class SlkjProjectTicketFareController extends BaseController {
    @Autowired
    private ISlkjProjectTicketFareService slkjProjectTicketFareService;

    /**
     * 票价管理
     */
    @PreAuthorize("@ss.hasPermi('system:fare:list')")
    @GetMapping("/list/{projectId}")
    public AjaxResult list(@PathVariable("projectId") Long projectId) {
        return slkjProjectTicketFareService.selectSlkjProjectTicketFareList(projectId);
    }

    /**
     * 获取项目_票价详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:fare:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(slkjProjectTicketFareService.selectSlkjProjectTicketFareById(id));
    }

    /**
     * 新增/编辑 项目_票价
     */
    @PreAuthorize("@ss.hasPermi('system:fare:add')")
    @Log(title = "新增/编辑_票价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectTicketFareManagementDto projectTicketFareManagementDto) {
        if (Objects.isNull(projectTicketFareManagementDto)) {
            return error("入参不能为空！");
        }
        log.info("项目 [project_id={}] 新增/编辑，票价管理，入参：{}.", projectTicketFareManagementDto.getProjectId(), JSON.toJSONString(projectTicketFareManagementDto));
        return slkjProjectTicketFareService.insertSlkjProjectTicketFare(projectTicketFareManagementDto, super.getUserId());
    }

    /**
     * 删除项目_票价
     */
    @PreAuthorize("@ss.hasPermi('system:fare:remove')")
    @Log(title = "项目_票价", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(slkjProjectTicketFareService.deleteSlkjProjectTicketFareByIds(ids));
    }
}
